import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace BookingEmergencyIncidentApi {
  /** 突发情况处理信息 */
  export interface BookingEmergencyIncident {
    id: number; // 突发情况ID
    incidentCode?: string; // 突发情况编码
    incidentType?: string; // 突发情况类型
    incidentTitle?: string; // 突发情况标题
    incidentDescription?: string; // 突发情况描述
    incidentSeverity?: string; // 严重程度
    affectedAreas: string; // 影响区域
    affectedResources: string; // 影响资源
    affectedOrders: string; // 影响订单
    incidentStartTime?: string | Dayjs; // 突发情况开始时间
    estimatedResolutionTime: string | Dayjs; // 预估解决时间
    actualResolutionTime: string | Dayjs; // 实际解决时间
    incidentDuration: number; // 突发情况持续时间(分钟)
    incidentStatus?: string; // 突发情况状态
    reporterId?: number; // 报告人ID
    assigneeId: number; // 处理人ID
    resolutionNotes: string; // 解决备注
    impactLevel: string; // 影响程度
    affectedCustomerCount: number; // 受影响客户数量
    estimatedLoss: number; // 预估损失
    storeId?: number; // 门店ID
    orgId?: number; // 组织ID
  }
}

/** 查询突发情况处理分页 */
export function getBookingEmergencyIncidentPage(params: PageParam) {
  return requestClient.get<
    PageResult<BookingEmergencyIncidentApi.BookingEmergencyIncident>
  >('/spa/booking-emergency-incident/page', { params });
}

/** 查询突发情况处理详情 */
export function getBookingEmergencyIncident(id: number) {
  return requestClient.get<BookingEmergencyIncidentApi.BookingEmergencyIncident>(
    `/spa/booking-emergency-incident/get?id=${id}`,
  );
}

/** 新增突发情况处理 */
export function createBookingEmergencyIncident(
  data: BookingEmergencyIncidentApi.BookingEmergencyIncident,
) {
  return requestClient.post('/spa/booking-emergency-incident/create', data);
}

/** 修改突发情况处理 */
export function updateBookingEmergencyIncident(
  data: BookingEmergencyIncidentApi.BookingEmergencyIncident,
) {
  return requestClient.put('/spa/booking-emergency-incident/update', data);
}

/** 删除突发情况处理 */
export function deleteBookingEmergencyIncident(id: number) {
  return requestClient.delete(
    `/spa/booking-emergency-incident/delete?id=${id}`,
  );
}

/** 导出突发情况处理 */
export function exportBookingEmergencyIncident(params: any) {
  return requestClient.download(
    '/spa/booking-emergency-incident/export-excel',
    { params },
  );
}
